<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateScheduleRulesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('schedule_rules', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('shopId')->default(0)->comment('店铺ID');
            $table->string('name', 32)->default('')->comment('班次名称');
            $table->time('start')->default('00:00')->comment('开始时间');
            $table->time('end')->default('00:00')->comment('结束时间');
            $table->unsignedTinyInteger('duration')->default(0)->comment('持续时间（小时）');
            $table->string('color', 16)->default('')->comment('颜色');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->tinyInteger('isDeleted')->comment(0);
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '排班 - 班次表';

            $table->index('shopId', 'idx_shopId');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('schedule_rules');
    }
}
